package com.turing.common.response;

import java.io.Serializable;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @author ：XiLuo
 * @Description 响应信息主体，返回的报文信息类
 * @date ：Created in 2019/6/3 10:24
 * @description：
 * @modified By：
 * @version: $
 */
@ApiModel(description = "默认返回结果对象")
@NoArgsConstructor
@AllArgsConstructor
@Builder(toBuilder = true)
@Accessors(chain = true)
@Data
public class ResponseVO<T> implements Serializable {

    /**
     * 响应码
     */
    @ApiModelProperty(value = "响应码", required = true)
    protected String code;

    /**
     * 响应消息
     */
    @ApiModelProperty(value = "响应消息", required = true)
    protected String message;

    /**
     * 响应数据
     */
    @ApiModelProperty(value = "响应数据")
    protected T data;

    /**
     * 响应状态-0失败，1成功
     */
    @ApiModelProperty(value = "响应状态-0失败，1成功")
    private Integer status;

    public ResponseVO(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public ResponseVO(String code, String message, int status) {
        this.code = code;
        this.message = message;
        this.status = status;
    }

    public ResponseVO(T data, String code, String message, int status) {
        this.data = data;
        this.code = code;
        this.message = message;
        this.status = status;
    }

    public static ResponseVO ErrorResponse(String paramsRequired, String convertObjectErrors) {

        return new ResponseVO(paramsRequired, convertObjectErrors);
    }

}
